package com.shujia.wyh.day27.network.tcpcoding;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class ClientDemo2 {
    public static void main(String[] args) throws Exception {
        //创建客户端的Socket对象
        Socket s = new Socket("192.168.10.112", 12345);

        //获取通道中的输出流对象，往与服务器连接通道中写入数据
        OutputStream os = s.getOutputStream();
        //获取通道中的输入流对象，接收服务器往通道中写入的反馈
//        InputStream is = s.getInputStream();

        while (true) {
            Scanner sc = new Scanner(System.in);
            String next = sc.next();
            //写给服务器的信息
            os.write(next.getBytes());
//            s.isOutputShutdown();

//            //接收服务器的反馈
//            byte[] bytes = new byte[1024];
//            int length = is.read(bytes);
//            String info = new String(bytes, 0, length);
//            System.out.println("服务器的反馈是：" + info);
        }
    }
}
